package com.pu.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pu.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

/**
 * @Author Yusc
 * @Date 2023/10/31 23:34
 * @Version
 * @Description 购物车管理
 **/
@Mapper
public interface ShoppingCartMapper extends BaseMapper<ShoppingCart> {
    /**
     * @param shoppingCart
     * @auther: Yusc
     * @date 2023/10/31 23:58
     * @Description 根据id修改数量
     */
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateNumberById(ShoppingCart shoppingCart);

    /**
     * @param userId 用户id

     * @auther: Yusc
     * @date 2023/11/2 13:23
     * @Description 通过用户id清空购物车
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long userId);


}
